﻿//var qqResult;
//var opId;
$(function () {
    //js SDK 登录代码坑爹的
    //QC.Login.signOut();
    //QC.Login({//按默认样式插入QQ登录按钮
    //    btnId: "qq-login"	//插入按钮的节点id
    //});
    //var paras = {};
    //QC.api("get_user_info", paras).success(function (s) {
    //    qqResult = s.data;
    //    QC.Login.getMe(function (openId, accessToken) {
    //        opId = openId;
    //        $.post('/account/qqlogin', { openId: opId, gender: qqResult.gender, nickname: qqResult.nickname }, function (o) {
    //            if (o.State == 1) {
    //                window.location.href = o.Url;
    //            }
    //        });
    //    })
    //}).error(function (f) {
    //    //失败回调
    //}).complete(function (c) {
    //    //完成请求回调
    //});
    $('#Account').focus();
    $('#qq-login').attr("onclick", "return window.open('https://graph.qq.com/oauth2.0/authorize?client_id=101333775&redirect_uri=" + encodeURI("http://www.xiaoboke.net/qc_back.html") + "&response_type=code&display=default&state=qq', 'newWindow', 'height=400, width=600, top=100, left=300, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')");
    $('#wb-login').attr("onclick", "return window.open('https://api.weibo.com/oauth2/authorize?client_id=1491702255&redirect_uri=" + encodeURI("http://www.xiaoboke.net/qc_back.html") + "&response_type=code&display=default&state=wb', 'newWindow', 'height=400, width=600, top=100, left=300, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')");
    $("#chkRemember").on("click", { chk: $("#chkRemember") }, isRemember);
    if (!isPC()) {
        $('#layer-bg').remove();
        $('.login').width($('.login').width() - 20);
    } else {
        setInterval(function () {
            l++;
            if (l > 3) {
                l = 1;
            }
            $("#layer-bg").animate({ opacity: 'toggle' }, "slow", null, function () {
                $("#layer-bg").attr("src", '/Content/Images/body-bg' + l + '.jpg');
                $("#layer-bg").animate({ opacity: 'toggle' }, "slow");
            });
        }, 5000);
    }
});
var l = 1;
function Success(obj) {
    $.showAjaxMessage(obj, $("#loginErr"), null);
}
function Fail(obj) {
    $("#loginErr").html("*系统错误，暂时无法登录");
}

function Begin() {
    $("#loginErr").html("登录中……");
    return true;
}

function CheckAgain() {
    if (!/^[A-Za-z0-9]{4,20}$/.test($.trim($('#Account').val()))) {
        $('#Account').next('span').text('*用户名为4-20位字母或数字');
        $("#Account").focus();
        return false;
    }
}

function isRemember(obj) {
    if (obj.data.chk.attr("checked") == "checked") {
        obj.data.chk.val(true);
    } else {
        obj.data.chk.val(false);
    }
}